package query

import (
	"ssadmin/common/query"
)

type SysLogQuery struct {
	query.Pagination `search:"-"`
	query.OrderBy    `search:"-"`
	query.UserInfo

	Username  string `form:"username" search:"type:contains;column:username;table:sys_operate_log"`
	Ip        string `form:"ip" search:"type:contains;column:ip;table:sys_operate_log"`
	Uri       string `form:"uri" search:"type:contains;column:uri;table:sys_operate_log"`
	Region    string `form:"region" search:"type:contains;column:region;table:sys_operate_log"`
	Method    string `form:"method" search:"type:exact;column:method;table:sys_operate_log"`
	Code      string `form:"code" search:"type:exact;column:code;table:sys_operate_log"`
	StartTime string `form:"startTime" search:"type:gte;column:operate_time;table:sys_operate_log"`
	EndTime   string `form:"endTime" search:"type:lte;column:operate_time;table:sys_operate_log"`

	AgencyIdEq string `search:"type:exact;column:agency_id;table:sys_operate_log"`
}

func (m *SysLogQuery) GetNeedSearch() interface{} {
	if m.UserId != "1" {
		m.AgencyIdEq = m.UserInfo.AgencyId
	}
	return *m
}
